<?php
/**
 * This is areas/admin_index template file. 
 *
 * @copyright     Copyright 2008-2010, LilCake.net
 * @link          http://lilcake.net LilCake.net
 * @package       lil
 * @subpackage    lil.views.areas
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
	$area_index = array(
		'title_for_layout' => __d('lil', 'Areas'),
		'menu' => array(
			'add' => array(
				'title' => __d('lil', 'Add', true),
				'visible' => true,
				'url'   => array(
					'admin'      => true,
					'plugin'     => 'lil',
					'controller' => 'areas',
					'action'     => 'add',
				)
			)
		),
		'actions' => array(
			'pre' => '',
			'post' => '',
			'lines' => array(
			)
		),
		'table' => array(
			'pre' => '<div class="index">' . PHP_EOL,
			'post' => '</div>',
			'element' => array(
				'parameters' => array(
					'cellspacing' => 0,
					'cellpadding' => 0,
					'id'          => 'AdminAreasIndex',
					'class'       => 'index'
				),
			)
		)
	);

	$area_index['table']['element']['head'] = array(
		'parameters' => array(),
		'rows' => array(
			0 => array(
				'columns' => array(
					'id' => array(
						'parameters' => array('class' => 'center'),
						'html' => __d('lil', 'ID')
					),
					'name' => array(
						'parameters' => array('class' => 'left'),
						'html' => __d('lil', 'Name')
					),
					Configure::read('Lil.areaSlugField') => array(
						'parameters' => array('class' => 'left'),
						'html' => __d('lil', 'Slug')
					),
					Configure::read('Lil.areaDescriptionField') => array(
						'parameters' => array('class' => 'left'),
						'html' => __d('lil', 'Description'),
					),
				)
			)
		)
	);
	
	// table body values
	$area_index['table']['element']['body']['rows'] = array();

	$i = 0;
	foreach($data as $item) {
		$area_index['table']['element']['body']['rows'][$i] = array(
			'data' => $item,
			'parameters' => ($i++ % 2 == 0) ? array() : array('class' => 'altrow'),
			'columns' => array(
				'id' => array(
					'parameters' => array('class' => 'center'),
					'html'       => $this->Text->truncate($item['Area']['id'], 10)
				),
				'name' => array(
					'parameters' => array('class' => 'big'),
					'html'       => $this->Html->link(
						$item['Area'][Configure::read('Lil.areaDisplayField')],
						array('action' => 'view', $item['Area']['id'])
					)
				),
				Configure::read('Lil.areaSlugField') => array(
					'html'       => $this->Html->clean($item['Area'][Configure::read('Lil.areaSlugField')])
				),
				'description' => array(
					'parameters' => array(),
					'html'       => 
						(isset($item['Area'][Configure::read('Lil.areaDescriptionField')])) ? 
						$this->Html->clean($item['Area'][Configure::read('Lil.areaDescriptionField')]) : '&nbsp;'
				),

			)
		);
		$i++;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// call plugin handlers
	$area_index = $this->callPluginHandlers('admin_index_areas', $area_index);
	
	$this->Lil->index($area_index);